package com.haoshuang.zhouzhoubang.ui.vm

import com.haoshuang.zhouzhoubang.model.api.ApiRepo
import com.haoshuang.zhouzhoubang.model.bean.OrderBean
import com.mufeng.libs.base.BaseViewModel
import com.mufeng.libs.net.netRequest
import com.mufeng.libs.state.StateData
import com.mufeng.libs.state.StatefulMutableLiveData


class AppointmentOrderViewModel : BaseViewModel() {

    /**
     * 获取预约订单列表
     */
    val getMasterAppointmentOrderListData = StatefulMutableLiveData<MutableList<OrderBean>>()
    fun getMasterAppointmentOrderList(page: Int) = netRequest {
        start { getMasterAppointmentOrderListData.value = StateData.Loading }
        request { ApiRepo.getMasterAppointmentOrderList(page) }
        success { getMasterAppointmentOrderListData.value = StateData.Success(it.data) }
        error { code, msg ->
            getMasterAppointmentOrderListData.value = StateData.Error(code, msg)
        }
    }
    
    /**
     * 提醒用户
     */
    val remindCheckData = StatefulMutableLiveData<Any>()
    fun remindCheck(orderId: String) = netRequest {
        start { remindCheckData.value = StateData.Loading }
        request { ApiRepo.remindCheck(orderId) }
        success { remindCheckData.value = StateData.Success(it.data) }
        error { code, msg ->
            remindCheckData.value = StateData.Error(code, msg)
        }
    }

}